<?xml version="1.0" encoding="UTF-8"?>
<!-- 
/**
 * Copyright 2011 MaGdev
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 *    * Redistributions of source code must retain the above copyright
 *      notice, this list of conditions and the following disclaimer.
 *    * Redistributions in binary form must reproduce the above copyright
 *      notice, this list of conditions and the following disclaimer in the
 *      documentation and/or other materials provided with the distribution.
 *    * The names of the authors may not be used to endorse or promote products
 *      derived from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
 * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 * @package      Mashape API-Documentor
 * @author       Marco Graetsch <info@magdev.de>
 * @copyright    2011 Marco Graetsch.development
 * @license      http://opensource.org/licenses/bsd-license.php New BSD License
 * @link         https://code.google.com/p/apidocumentor/
 */
 -->
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:import href="pages.xsl"/>
    
    <xsl:param name="title" />
    <xsl:param name="description" />
    <xsl:param name="apiUrl" />
    <xsl:param name="authorName" />
    <xsl:param name="authorUrl" />
    <xsl:param name="version" />
    <xsl:param name="license" />
    <xsl:param name="licenseUrl" />
    <xsl:param name="component" />
    <xsl:param name="home" select="'http://code.google.com/p/apidocumentor/'"/>
    <xsl:param name="mashdocVersion" select="'0.3'" />
    <xsl:param name="themeCssURI" select="'assets/default/themes/default.css'" />
    <xsl:param name="apiCssURI" select="'assets/api.css'"/>
    <xsl:param name="jqueryMobileCssURI" select="'http://code.jquery.com/mobile/1.0b1/jquery.mobile-1.0b2.min.css'" />
    <xsl:param name="jqueryMobileJsURI" select="'http://code.jquery.com/mobile/1.0b1/jquery.mobile-1.0b2.min.js'" />
    <xsl:param name="jqueryJsURI" select="'http://code.jquery.com/jquery-1.6.2.min.js'" />
    
    
    <xsl:output method="html" encoding="UTF-8" indent="yes" media-type="text/html" />
    
	<xsl:template match="/">
        <html>
            <head>
                <xsl:call-template name="meta" />
            </head>
            <body class="skin-mashape">
                <xsl:call-template name="pages" />
                
                <xsl:apply-templates select="//object" />
                <xsl:apply-templates select="//method" />
                <xsl:apply-templates select="//method/url" />
            </body>
        </html>
    </xsl:template>
    
    
    <xsl:template name="meta">
        <title>
            <xsl:value-of select="$title" />
            <xsl:text> | API Documentation</xsl:text>
        </title>
        <meta charset="UTF-8" />
        <xsl:element name="meta">
            <xsl:attribute name="name">author</xsl:attribute>
            <xsl:attribute name="content">
                <xsl:text>Mashape-Documentor v</xsl:text>
                <xsl:value-of select="$mashdocVersion" />
            </xsl:attribute>
        </xsl:element>
        <xsl:element name="meta">
            <xsl:attribute name="name">description</xsl:attribute>
            <xsl:attribute name="content">
                <xsl:value-of select="title" />
                <xsl:text> API Pocket-Reference by </xsl:text>
                <xsl:value-of select="$authorName" />
            </xsl:attribute>
        </xsl:element>
        <xsl:element name="meta">
            <xsl:attribute name="name">author</xsl:attribute>
            <xsl:attribute name="content"><xsl:value-of
                select="$authorName" /></xsl:attribute>
        </xsl:element>
        <xsl:element name="link">
            <xsl:attribute name="rel">stylesheet</xsl:attribute>
            <xsl:attribute name="href"><xsl:value-of
                select="$themeCssURI" /></xsl:attribute>
        </xsl:element>
        <xsl:if test="$apiCssURI!=''">
	        <xsl:element name="link">
	            <xsl:attribute name="rel">stylesheet</xsl:attribute>
	            <xsl:attribute name="href"><xsl:value-of
	                select="$apiCssURI" /></xsl:attribute>
	        </xsl:element>
        </xsl:if>
        <xsl:element name="link">
            <xsl:attribute name="rel">stylesheet</xsl:attribute>
            <xsl:attribute name="href"><xsl:value-of
                select="$jqueryMobileCssURI" /></xsl:attribute>
        </xsl:element>
        <xsl:element name="script">
            <xsl:attribute name="type">text/javascript</xsl:attribute>
            <xsl:attribute name="src"><xsl:value-of
                select="$jqueryJsURI" /></xsl:attribute>
        </xsl:element>
        <xsl:element name="script">
            <xsl:attribute name="type">text/javascript</xsl:attribute>
            <xsl:attribute name="src"><xsl:value-of
                select="$jqueryMobileJsURI" /></xsl:attribute>
        </xsl:element>
    </xsl:template>
    
    
    
    <xsl:template name="menu">
        <nav data-role="navbar" data-iconpos="left">
            <ul>
                <li>
                    <a rel="home" data-icon="home" data-theme="a" data-transition="slide" href="#home" data-direction="reverse">
                        <xsl:text>Home</xsl:text>
                    </a>
                </li>
                <li>
                    <a data-icon="grid" data-theme="a" data-transition="slide" href="#objects" data-direction="reverse">
                        <xsl:text>Objects</xsl:text>
                    </a>
                </li>
                <li>
                    <a data-icon="gear" data-theme="a" href="#methods" data-transition="slide">
                        <xsl:text>Methods</xsl:text>
                    </a>
                </li>
                <xsl:if test="$component!=''">
                    <li>
	                    <a data-icon="help" data-theme="a" href="#howto" data-transition="slide">
	                        <xsl:text>How-To</xsl:text>
	                    </a>
	                </li>
	            </xsl:if>
            </ul>
        </nav>
    </xsl:template>
    
    
    
    <xsl:template name="footer">
        <footer data-role="footer" data-position="fixed" data-id="footer">
            <nav data-role="navbar" data-iconpos="left">
                <ul>
                    <xsl:if test="$apiUrl!=''">
                        <li>
	                        <xsl:element name="a">
	                            <xsl:attribute name="href">
	                                <xsl:value-of select="$apiUrl" />
	                            </xsl:attribute>
	                            <xsl:attribute name="rel">external</xsl:attribute>
	                            <xsl:attribute name="data-theme">a</xsl:attribute>
	                            <xsl:attribute name="data-icon">home</xsl:attribute>
	                            <xsl:value-of select="$title" />
	                        </xsl:element>
	                    </li>
	                </xsl:if>
                    <xsl:if test="$authorUrl!=''">
	                    <li>
	                        <xsl:element name="a">
	                            <xsl:attribute name="href">
	                                <xsl:value-of select="$authorUrl" />
	                            </xsl:attribute>
	                            <xsl:attribute name="rel">external</xsl:attribute>
	                            <xsl:attribute name="data-theme">a</xsl:attribute>
	                            <xsl:attribute name="data-icon">info</xsl:attribute>
	                            <xsl:value-of select="$authorName" />
	                        </xsl:element>
	                    </li>
	                </xsl:if>
                    <li>
                        <a data-icon="star" data-theme="a" href="http://www.mashape.com" rel="external">
                            <xsl:text>Mashape</xsl:text>
                        </a>
                    </li>
                </ul>
            </nav>
            <div class="copyright">
                <xsl:text>Mashape-Documentor v</xsl:text>
                <xsl:value-of select="$mashdocVersion" />
                <xsl:text> | Copyright 2011 </xsl:text>
                <xsl:element name="a">
                    <xsl:attribute name="href"><xsl:value-of select="$home"/></xsl:attribute>
                    <xsl:attribute name="title">Marco Grätsch.development</xsl:attribute>
                    <xsl:text>www.magdev.de</xsl:text>
                </xsl:element>
            </div>
        </footer>
    </xsl:template>
    
    
    


    <xsl:template match="field">
        <li>
            <xsl:value-of select="." />
            <xsl:if test="@optional='true'">
                <span class="ui-li-aside optional brackets">optional</span>
            </xsl:if>
        </li>
    </xsl:template>




    <xsl:template match="url">

    </xsl:template>


    <xsl:template match="parameters">
        <li data-role="list-divider" class="subheading">Parameter</li>
        <xsl:for-each select="parameter">
            <li>
                <xsl:value-of select="." />
                <xsl:if test="@optional='true'">
                    <span class="optional brackets">optional</span>
                </xsl:if>
            </li>
        </xsl:for-each>
    </xsl:template>


    <xsl:template match="result">
        <li data-role="list-divider" class="subheading">
            <xsl:text>Result</xsl:text>
            <span class="object-type brackets">
                <xsl:value-of select="@type" />
            </span>
        </li>
        <li>
            <xsl:element name="a">
                <xsl:attribute name="href">
                    <xsl:value-of select="concat('#object', @name)" />
                </xsl:attribute>
                <xsl:attribute name="data-direction">reverse</xsl:attribute>
                <xsl:value-of select="@object" />
                <xsl:if test="@array='true'">
                    <xsl:text>[]</xsl:text>
                </xsl:if>
            </xsl:element>
        </li>
    </xsl:template>


    <xsl:template match="error">
        <li data-role="list-divider" class="subheading">
            <xsl:text>Error</xsl:text>
        </li>
        <li>
            <xsl:element name="a">
                <xsl:attribute name="href">
                    <xsl:value-of select="concat('#object', @name)" />
                </xsl:attribute>
                <xsl:attribute name="data-direction">reverse</xsl:attribute>
                <xsl:value-of select="@object" />
                <xsl:if test="../result[@array='true']">
                    <xsl:text>[]</xsl:text>
                </xsl:if>
            </xsl:element>
        </li>
    </xsl:template>
    
</xsl:stylesheet>